#
# tmpl.py 
# 
# Copyright 2011 Matt Whipple <matt@mattwhipple.com>
# 
# This file is part of com.teamsuperfitness.www
#
# com.teamsuperfitness.www is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your option)
# any later version.
# 
# com.teamsuperfitness.www is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
# 
# You should have received a copy of the GNU General Public License along
# with com.teamsuperfitness.www. If not, see http://www.gnu.org/licenses/.
#

from mako.template import Template
from mako.lookup import TemplateLookup

import os

def render_template(path, context={}):
    """Takes a path to template and calls the template engine to generate a string"""
    mako_lookup = TemplateLookup(directories=["%s/templates" % os.path.dirname(__file__)])
    template_path = "%s.mak" % (path)
    template = mako_lookup.get_template(template_path)

    return template.render(**context)
